package com.example.door17;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.widget.GridLayout;
import android.widget.GridView;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        intview();
    }
    public void intview(){
        RecyclerView recyclerView=findViewById(R.id.recy_in);
//LinearLayoutManager默认情况下是垂直即vertical
        LinearLayoutManager llm=new LinearLayoutManager(this);
       // llm.setOrientation(LinearLayoutManager.VERTICAL);
       // llm.setOrientation(LinearLayoutManager.HORIZONTAL);
        //GridView
        //GridLayoutManager gle=new GridLayoutManager(this,4);
        //网格模式，默认垂直，给定默认列
        //网格模式，设定水平后，原本的列数变为行数
        GridLayoutManager glm=new GridLayoutManager(this,4,GridLayoutManager.VERTICAL,true);
        recyclerView.setLayoutManager(glm);
        //recyclerView.setLayoutManager(llm);
        List<ContactModle> list=new ArrayList<>();
        for(int i=0;i<20;i++){
            ContactModle con=new ContactModle();
            con.setContactname("张三"+i);
            con.setContactid(R.mipmap.ic_launcher);
            list.add(con);
        }
        Adaper adaper=new Adaper(MainActivity.this);
        adaper.setData(list);
        recyclerView.setAdapter(adaper);
    }
}